﻿<?php
/**
 * Zead
 *
 * LICENSE	
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.opensource.org/licenses/bsd-license.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to eu@marcelomx.com so we can send you a copy immediately.
 *
 * @category   Zead
 * @author     Marcelo Rodrigues Gonzaga <eu@marcelomx.com>
 * @copyright  Copyright (c) 2008 Marcelo Rodrigues Gonzaga
 * @link       http://code.google.com/p/zead 
 * @license    http://www.opensource.org/licenses/bsd-license.php     New BSD License
 *
 **/


/** @see Zead_Html_Helper_HeadLink **/
require_once 'Zead/Html/Helper/HeadLink.php';

/**
 * @category   Zead
 * @package    Zead_Html
 * @subpackage Zead_Html_Helper
 * @copyright  Copyright (c) 2008 Marcelo Rodrigues Gonzaga 
 * @license    http://www.opensource.org/licenses/bsd-license.php     New BSD License  
 */
class Zead_Html_Helper_HeadStyle extends Zead_Html_Helper_HeadLink {
	/**
	 * Os tipos de atributos permitidos a este tipo de link em específico.
	 * @var string
	 */
	protected $_attributeType  = array('text/css', 'text/javascript');
	
	/**
	 * Os tipos de mídia utilizadas pelas folhas de estilo
	 * @var array
	 */
	protected $_attributeMedia = array('all', 'screen', 'print', 'aural', 'tv', 'projection', 'handheld');
	
	/**
	 * Os tipos de atributos rel permitidos para as folhas de estilo
	 * @var array
	 */
	protected $_attributeRel   = array('stylesheet', 'alternate stylesheet');	
	
	/**
	 * Aplica a criação do elemento estilo no cabecalho do documento.
	 *
	 * @param string $href
	 * @param string $media
	 * @param string $title
	 * @param string $type
	 * @param array  $attributes
	 */
	public function headStyle($href, $media = null, $title = null, $type = 'text/css', array $attributes = array()) {
		$style = $this->html->head()->appendChild($this->html->createElement('link'));
		$style->setAttributes(array(
			'href'  => $href,
			'media' => !in_array($media,$this->_attributeMedia) ? $this->_attributeMedia[0] : $media,
			'type'  => !in_array($type,$this->_attributeType) ? $this->_attributeType[0] : $type,
			'rel'   => !in_array($rel,$this->_attributeRel) ? $this->_attributeRel[0] : $rel,
			'title' => $title
		));

		return $style;
	}	
}


